import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  DeviceWarnQuery,
  DeviceWarnPageResult,
  DeviceWarnForm,
} from "./warnSettingTypes";

/**
 * 获取设备预警分页数据
 *
 * @param queryParams
 */
export function getDeviceWarnPage(
  queryParams?: DeviceWarnQuery
): AxiosPromise<DeviceWarnPageResult> {
  return request({
    url: "/api/v1/deviceWarnSetting/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取设备预警详情
 *
 * @param id
 */
export function getDeviceWarnForm(id: number): AxiosPromise<DeviceWarnForm> {
  return request({
    url: "/api/v1/deviceWarnSetting/" + id + "/form",
    method: "get",
  });
}

/**
 * 设置设备预警
 *
 * @param data
 */
export function setDeviceWarn(data: DeviceWarnForm) {
  return request({
    url: "/api/v1/deviceWarnSetting/addOrUpdate",
    method: "post",
    data: data,
  });
}
